package com.linght.captcha;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.captcha.ShearCaptcha;
import cn.hutool.captcha.generator.RandomGenerator;
import cn.hutool.core.lang.Console;

/**
 * Description:
 * User:岁亮亮
 * Date:2024-11-11
 * TIME:12:40
 */
public class Captcha_test {
    public static void main(String[] args) {
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200,100);
        lineCaptcha.createCode();
        Console.log(lineCaptcha.getCode());
        System.out.println(lineCaptcha.verify("1234"));

        System.out.println("====================");
        CircleCaptcha circleCaptcha = CaptchaUtil.createCircleCaptcha(200,100);
        circleCaptcha.createCode();
        Console.log(circleCaptcha.getCode());
        System.out.println(lineCaptcha.verify("1234"));
        System.out.println("=====================");
        RandomGenerator randomGenerator = new RandomGenerator("123456789",4);
        LineCaptcha lineCaptcha1 = CaptchaUtil.createLineCaptcha(200,100);
        lineCaptcha1.setGenerator(randomGenerator);
        lineCaptcha1.createCode();
        Console.log(lineCaptcha1.getCode());
        System.out.println(lineCaptcha1.verify("1234"));

    }
    public static void main1(String[] args) {
        //定义图形验证码的长和宽
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
        //图形验证码写出，可以写出到文件，也可以写出到流
        lineCaptcha.write("d:/line.png");

       //定义图形验证码的长、宽、验证码字符数、干扰元素个数
        CircleCaptcha circleCaptchacaptcha = CaptchaUtil.createCircleCaptcha(200, 100, 4, 20);
//CircleCaptcha captcha = new CircleCaptcha(200, 100, 4, 20);
//图形验证码写出，可以写出到文件，也可以写出到流
        circleCaptchacaptcha.write("d:/circle.png");


        //定义图形验证码的长、宽、验证码字符数、干扰线宽度
        ShearCaptcha shearCaptchacaptcha = CaptchaUtil.createShearCaptcha(200, 100, 4, 4);
//ShearCaptcha captcha = new ShearCaptcha(200, 100, 4, 4);
//图形验证码写出，可以写出到文件，也可以写出到流
        shearCaptchacaptcha.write("d:/shear.png");
//验证图形验证码的有效性，返回boolean值

    }
}
